{% extends 'base.html' %}

{% block content %}
    {% for post in posts.items %}
        <div class="media">
            <img src="{{ url_for('static', filename='avatars/' + post.user.avatar) }}" class="rounded-circle"
                 width="80" height="80" alt="头像">

            <div class="media-body">
                <h5 class="mt-0"><a href="{{ url_for('post.post_detail', post_id=post.id) }}">{{ post.title }}</a></h5>
                <small class="text-muted">作者: <a class="text-sm"
                                                 href="{{ url_for('auth.user_posts', username=post.user.username) }}">{{ post.user.username }}</a>
                    创建于 {{ post.created.strftime('%Y-%m-%d %H:%M') }}</small>
                <p>{{ post.content }}</p>
            </div>
        </div>
        <hr>
    {% endfor %}
{#    pagination#}
    {% for page_num in posts.iter_pages(left_edge=1, right_edge=1, left_current=1, right_current=2) %}
        {% if page_num %}
            {% if posts.page == page_num %}
                <a class="btn btn-info mb-4" href="{{ url_for('main.index', page=page_num) }}">{{ page_num }}</a>
            {% else %}
                <a class="btn btn-outline-info mb-4" href="{{ url_for('main.index', page=page_num) }}">{{ page_num }}</a>
            {% endif %}
        {% else %}
            ...
        {% endif %}
    {% endfor %}
{% endblock %}
